Skip to content

Development: Reuse compliance analysis across languages via snippet mapping - #2470

Open
ge94zec wants to merge 33 commits into
mainfrom
chore/2346-enhance-performance-for-compliance
Open

Development: Reuse compliance analysis across languages via snippet mapping #2470
ge94zec wants to merge 33 commits into
mainfrom
chore/2346-enhance-performance-for-compliance

Conversation

@ge94zec

@ge94zec ge94zec commented May 5, 2026

Copy link
Copy Markdown
Contributor

Checklist

General

Server

Client

  • Important: I implemented the changes with a very good performance, prevented too many (unnecessary) REST calls and made sure the UI is responsive, even with large data (e.g. using paging).
  • I strictly followed the principle of data economy for all client-server REST calls.
  • I strictly followed the client coding and design guidelines.

Motivation and Context

Closes: #2346

Description

This change improves the bilingual AI compliance workflow for job descriptions by replacing the second target-language compliance analysis with a snippet mapping. The editor now analyzes the source language once in analyzeJobDescription, streams and stores the translated text in translateTextStream, and then maps the detected compliance snippets onto the translated version automatically mapComplianceIssues. This reduces duplicate AI work, keeps translated highlights in sync with sourceIssues.

The duplicated compliance issue persistence logic in JobService was extracted into a shared helper. Since the Score is currently a combined value derived from both gender and legal analysis, this ensures the score remains consistent and is only updated when a full, valid recalculation is possible.

LLM compliance calls per autosave cycle is now reduced from 2 to 1. The translation with second analysis is reduced from 11s to approximately 2.30s.

Steps for Testing

Prerequisites:

  1. Log in to TUMApply as Prof
  2. Nav to Create position
  3. Verify that the complianceAnalysis of target stays within a 2-second threshold

Review Progress

Code Review

  • Code Review 1

Manual Tests

  • Test 1

Screenshots

Bildschirmfoto 2026-05-09 um 19 08 15

Test Coverage

Client

Class/File Line Coverage Lines Expects Ratio
job-creation-form.component.ts 72.64% 1284 96 7.5
editor.component.ts 50.45% 369 28 7.6

Server

Class/File Line Coverage Lines
MapComplianceIssuesRequestDTO.java 100.00% 14
AiService.java 21.88% 386
SnippetMatcher.java 100.00% 7
AiResource.java 48.15% 99
JobService.java 72.88% 385

Last updated: 2026-08-19 15:33:20 UTC

…rget text

- added endpoint POST that maps source issues to a target language
- added prompt that returns one mapped text snippet
  per line in source complianceIssues order, other fields carry over
- wired compliance mapping through client → server API
- separated compliance analysis from score calculation
- extracted save flow in JobService into Consumer
- improved performance by eliminating redundant analysis steps in job creation
@ge94zec ge94zec linked an issue May 5, 2026 that may be closed by this pull request
@github-actions github-actions Bot added server Pull requests that update Java code. (Added Automatically!) client Pull requests that update TypeScript code. (Added Automatically!) job Code changes in job module. labels May 5, 2026
@codacy-production

codacy-production Bot commented May 5, 2026

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 1 medium

Alerts:
⚠ 1 issue (≤ 0 issues of at least minor severity)

Results:
1 new issue

Category Results
Complexity 1 medium

View in Codacy

🟢 Metrics 8 complexity

Metric Results
Complexity 8

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

📊 Server Test Coverage Too Low

🔍 View coverage locally:

./gradlew test jacocoTestReport
open build/reports/jacoco/test/html/index.html

🌐 View coverage from GitHub:
Download the "coverage-report-server" artifact from this workflow run.

@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

📊 Server Test Coverage Too Low

🔍 View coverage locally:

./gradlew test jacocoTestReport
open build/reports/jacoco/test/html/index.html

🌐 View coverage from GitHub:
Download the "coverage-report-server" artifact from this workflow run.

@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

🤖 No OpenAPI or client changes needed.

@ge94zec ge94zec changed the title Chore: Reuse compliance analysis across languages via snippet mapping Development: Reuse compliance analysis across languages via snippet mapping May 5, 2026
- updated openapi
- added comment to AiService
- simplified AiService mapping
- updated prompt
@github-actions github-actions Bot added the tests label May 5, 2026
@ge94zec ge94zec changed the title Development: Reuse compliance analysis across languages via snippet mapping Development: Reuse compliance analysis across languages via snippet mapping May 5, 2026
@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

📊 Server Test Coverage Too Low

🔍 View coverage locally:

./gradlew test jacocoTestReport
open build/reports/jacoco/test/html/index.html

🌐 View coverage from GitHub:
Download the "coverage-report-server" artifact from this workflow run.

@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

📊 Client Test Coverage Too Low

🔍 View coverage locally:

npm run test:ci
open build/test-results/vitest/coverage/index.html

🌐 View coverage from GitHub:
Download the "coverage-report-client" artifact from this workflow run.

@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

🤖 No OpenAPI or client changes needed.

@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

📊 Server Test Coverage Too Low

🔍 View coverage locally:

./gradlew test jacocoTestReport
open build/reports/jacoco/test/html/index.html

🌐 View coverage from GitHub:
Download the "coverage-report-server" artifact from this workflow run.

@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

🤖 No OpenAPI or client changes needed.

@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

📊 Client Test Coverage Too Low

🔍 View coverage locally:

npm run test:ci
open build/test-results/vitest/coverage/index.html

🌐 View coverage from GitHub:
Download the "coverage-report-client" artifact from this workflow run.

ge94zec added 2 commits May 9, 2026 02:39
- make job authorization check reusable in JobService
- check job access before mapping compliance issues
- Clear target-language issues in DB when source list is empty
- skip target mapping when source analysis was skipped/failed
…or-compliance' into chore/2346-enhance-performance-for-compliance
@github-actions

github-actions Bot commented May 9, 2026

Copy link
Copy Markdown
Contributor

📊 Server Test Coverage Too Low

🔍 View coverage locally:

./gradlew test jacocoTestReport
open build/reports/jacoco/test/html/index.html

🌐 View coverage from GitHub:
Download the "coverage-report-server" artifact from this workflow run.

@github-actions

github-actions Bot commented May 9, 2026

Copy link
Copy Markdown
Contributor

🤖 No OpenAPI or client changes needed.

@codacy-production

codacy-production Bot commented May 9, 2026

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 3 medium

Alerts:
⚠ 3 issues (≤ 0 issues of at least minor severity)

Results:
3 new issues

Category Results
Complexity 3 medium

View in Codacy

🟢 Metrics 10 complexity

Metric Results
Complexity 10

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@github-actions

github-actions Bot commented May 9, 2026

Copy link
Copy Markdown
Contributor

📊 Server Test Coverage Too Low

🔍 View coverage locally:

./gradlew test jacocoTestReport
open build/reports/jacoco/test/html/index.html

🌐 View coverage from GitHub:
Download the "coverage-report-server" artifact from this workflow run.

@github-actions

github-actions Bot commented May 9, 2026

Copy link
Copy Markdown
Contributor

🤖 No OpenAPI or client changes needed.

@codacy-production

codacy-production Bot commented Aug 1, 2026

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 1 high · 1 medium

Alerts:
⚠ 2 issues (≤ 0 issues of at least minor severity)

Results:
2 new issues

Category Results
Security 1 high
Complexity 1 medium

View in Codacy

🟢 Metrics 18 complexity

Metric Results
Complexity 18

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

📊 Server Test Coverage Too Low

🔍 View coverage locally:

./gradlew test jacocoTestReport
open build/reports/jacoco/test/html/index.html

🌐 View coverage from GitHub:
Download the "coverage-report-server" artifact from this workflow run.

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

🤖 No OpenAPI or client changes needed.

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

🤖 No OpenAPI or client changes needed.

@github-actions github-actions Bot removed the stale label Aug 2, 2026
@github-actions

Copy link
Copy Markdown
Contributor

There hasn't been any activity on this pull request recently. Therefore, this pull request has been automatically marked as stale and will be closed if no further activity occurs within seven days. Thank you for your contributions.

@github-actions github-actions Bot added the stale label Aug 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🤖 No OpenAPI or client changes needed.

@helios-aet
helios-aet Bot deployed to test-server August 17, 2026 10:03 Active
ge94zec and others added 2 commits August 17, 2026 13:29
- map source findings to exact translated snippets
- preserve issue metadata and persist mapped findings
- reject invalid mapping responses
- refine compliance and snippet-mapping prompts
- ignore empty mapped snippets during editor highlighting
- simplify focused mapping tests
@github-actions

Copy link
Copy Markdown
Contributor

🤖 OpenAPI spec and client code auto-updated and committed.

@github-actions

Copy link
Copy Markdown
Contributor

📊 Client Test Coverage Too Low

🔍 View coverage locally:

pnpm run test:ci
open build/test-results/vitest/coverage/index.html

🌐 View coverage from GitHub:
Download the "coverage-report-client" artifact from this workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

🤖 No OpenAPI or client changes needed.

…or-compliance' into chore/2346-enhance-performance-for-compliance
@github-actions

Copy link
Copy Markdown
Contributor

🤖 No OpenAPI or client changes needed.

@helios-aet
helios-aet Bot deployed to test-server August 17, 2026 12:12 Active
@github-actions

Copy link
Copy Markdown
Contributor

🤖 No OpenAPI or client changes needed.

@az108 az108 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed on top of Cathy's existing review — none of the points below overlap with hers.

The core idea is right: snippet mapping instead of a second full-text analysis is exactly the lever worth pulling here, and applyJobChangeForAnalysis quietly adds the first ownership check on this path — updateAiAnalysis had none on main. Raw ListList<ComplianceIssue> is a good catch too.

The prompt rewrite that ships with it is broken, though.

Blocking

1. {format} breaks every compliance analysis (AnalyzeComplianceText.st:59) — unresolved template variable, StTemplateRenderer defaults to ValidationMode.THROW. Reproduced against the real Spring AI 2.0.0-M4 jars; details inline.

2. Output contract no longer matches ComplianceIssue (AnalyzeComplianceText.st:52) — the prompt asks for text, category, suggestion, but there is no suggestion field anywhere in the project, and article / explanation / action are no longer requested at all. The compliance popover renders nothing but article and explanation.

3. {userLang} silently dropped (AnalyzeComplianceText.st:9) — the parameter is still passed from client through resource to service, and the JavaDoc still promises it controls the explanation language. It no longer does anything.

4. jobId has no Bean Validation (MapComplianceIssuesRequestDTO.java:13) — a request without it runs the LLM mapping, returns 200, and persists nothing without any error or log.

A general note on 1–3: the prompt rewrite looks unrelated to "reuse compliance analysis across languages via snippet mapping". Splitting it into its own PR would have surfaced these — the mapping logic itself is sound.

Test coverage

62be17d06 "removed tests" deletes AiServiceTest.java (418 lines) including five tests for mapComplianceIssues, with no resource-level replacement. That follows the no-*ServiceTest rule, but it leaves the empty-source-issues early return, the LLM catch branch, the size/null mismatch branch, and — most importantly — the silent dropping of non-verbatim snippets (continue after SnippetMatcher.isVerbatim) completely uncovered. SnippetMatcherTest only covers the trivial helper.

Things I checked and found fine

Listing these so they don't come up in a later round:

  • LLM call before the ownership check in mapComplianceIssues — consistent with analyzeJobDescription and extractPdfData, and this PR improves the situation rather than worsening it. isAdminOrMemberOf returns void and throws AccessDeniedException, so nothing is being silently ignored.
  • let finalContent: string | null = null — the type is forced by the pre-existing extractTranslatedTextFromStream(): string | null; no lint rule against null, and it appears in 77 of 267 client files.
  • The if (!jobId) return moved to the top of translateAndStoreOtherLanguage — both callers run after an awaited saveDraft with no await in between, so it is unreachable defence, not a behaviour change.
  • void-ed analysis promise in processDescriptionWithAianalyzeAndUpdateScore has nothing throwable outside its try, and main had the same shape with void Promise.all([...]).
  • Fully-qualified java.util.stream.IntStream — 19 comparable spots in src/main/java, no checkstyle or Spotless gate on imports.
  • postAndRead(..., Void.class, 400) without assertThatpostInvalid asserts the status itself; 81 test methods in the repo do it this way.
  • toHaveBeenCalledWith instead of toHaveBeenCalledOnce — the rule targets call-count assertions; 468 of 546 toHaveBeenCalledWith in the repo carry no count assertion.

Comment thread src/main/resources/prompts/AnalyzeComplianceText.st Outdated
Comment thread src/main/resources/prompts/AnalyzeComplianceText.st Outdated
Comment thread src/main/resources/prompts/AnalyzeComplianceText.st Outdated
Comment thread src/main/java/de/tum/cit/aet/ai/dto/MapComplianceIssuesRequestDTO.java Outdated
@github-actions github-actions Bot removed the stale label Aug 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🤖 OpenAPI spec and client code auto-updated and committed.

@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 1 high · 1 medium

Alerts:
⚠ 2 issues (≤ 0 issues of at least minor severity)

Results:
2 new issues

Category Results
Security 1 high
Complexity 1 medium

View in Codacy

🟢 Metrics 29 complexity

Metric Results
Complexity 29

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@github-actions

Copy link
Copy Markdown
Contributor

🤖 No OpenAPI or client changes needed.

@ge94zec
ge94zec requested a review from az108 August 19, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client Pull requests that update TypeScript code. (Added Automatically!) job Code changes in job module. server Pull requests that update Java code. (Added Automatically!) tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhance performance for compliance

3 participants